import GridRow from "../../../../../../frappe/frappe/public/js/frappe/form/grid_row";

export default class NewGridRow extends GridRow {
    add_open_form_button() {
		var me = this;
		if (this.doc && !this.grid.df.in_place_edit) {
			// remove row
			if (!this.open_form_button) {
				this.open_form_button = $('<div class="col edit"></div>').appendTo(this.row);

				if (!this.configure_columns) {
					this.open_form_button = $(`
						<div class="btn-open-row">
							<a>${frappe.utils.icon("edit", "xs")}</a>
							<div class="hidden-md edit-grid-row">${__("Edit", "", "Edit grid row")}</div>
						</div>
					`)
						.appendTo(this.open_form_button)
						.on("click", function () {
							me.toggle_view();
							return false;
						});
				}

				if (this.is_too_small()) {
					// narrow
					this.open_form_button.css({ "margin-right": "-2px" });
				}
			}
		}
	}

	validate_columns_width() {
		let total_column_width = 0.0;

		this.selected_columns_for_grid.forEach((row) => {
			if (row.columns && row.columns > 0) {
				total_column_width += cint(row.columns);
			}
		});

		// if (total_column_width && total_column_width > 10) {
		// 	frappe.throw(__("The total column width cannot be more than 10."));
		// }
	}


}

// frappe.ui.form.GridRow = NewGridRow